﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DBSourceToolsLib.SysObjects
{
    public class ColInfo
    {
        public string Name;
        public string Type;
        public bool PrimaryKey;
        public bool NeedsQuotes()
        {
            switch (Type)
            {
                case "varchar":
                case "char":
                case "datetime":
                case "nchar":
                case "ntext":
                case "nvarchar":
                case "smalldatetime":
                case "text":
                case "timestamp":
                case "uniqueidentifier":
                case "xml":
                    return true;
                default:
                    return false;

            }

        }
        public bool IsBinary()
        {
            switch (Type)
            {
                case "bit":
                    return true;
                default:
                    return false;
            }
        }

        public bool IsDateTime()
        {
            switch (Type)
            {
                case "datetime":
                case "smalldatetime":
                case "timestamp":
                    return true;
                default:
                    return false;

            }
        }

        public bool IsIdentity;
        public bool IsNullable;

        public bool IsUniqueIdentifier()
        {
            switch (Type)
            {
                case "uniqueidentifier":
                    return true;
                default:
                    return false;

            }

        }

        public String NameAndType { get { return Name + " (" + Type + ")"; } }
    }
}
